class_name GhostTetromino
extends Node2D

@onready var piece_scene = preload("res://Sence/piece.tscn")
@onready var ghost_texture = preload("res://Assets/鬼魂方块.png")

var tetromino_data : Resource

func _ready()->void:
	var tetromino_cells = Shared.Cells[tetromino_data.piece_type]
	
	for cell in tetromino_cells:
		var piece = piece_scene.instantiate() as Piece
		add_child(piece)
		piece.set_texture(ghost_texture)
		piece.position = cell * piece.get_size()
		
func set_ghost_tetromino_position(new_pos:Vector2,pieces_position):
	global_position = new_pos
	
	var pieces = get_children()
	for i in pieces.size():
		pieces[i].position = pieces_position[i]
